// layui.use(['table','layer','form'], function(){ //独立版的layer无需执行这一句
//     let $ = layui.jquery, layer = layui.layer , table = layui.table , form = layui.form; //独立版的layer无需执行这一句
//
//     //触发事件
//     let active = {
//         confirmTrans: function(){
//             //配置一个透明的询问框
//             layer.msg('是否确认', {
//                 time: 20000, //20s后自动关闭
//                 btn: ['确认', '取消']
//             });
//         }
//     };
//     $('#layerDemo .layui-btn').on('click', function(){
//         let othis = $(this), method = othis.data('method');
//         active[method] ? active[method].call(this, othis) : '';
//     });
//
//
//
// });
function ff() {
    layui.use(['jquery', 'layer', 'form'], function () {
        let $ = layui.jquery, layer = layui.layer, form = layui.form;
        // 显示更新用户表单的弹出层
        let send = layer.open({
            type: 1,
            title: '请选择简历',
            skin: 'layui-layer-molv',
            area: ['500px'],
            content: $('#update-layer'),
            cancel: function () {
                // 右上角关闭事件的逻辑
                layer.close(send);
                $("#update-layer").css("display", "none");
            }
        });
        layer.style(send, {
            width: '400px',
            height: '250px'
        });
        form.on('submit(update-form-submit)', function () {



            // 遍历单选框
            let rd = document.getElementsByName("res");
            // 定义一个变量表示选择的简历个数
            let count = 0;
            for(let i = 0; i<rd.length;i++){
                if(rd[i].checked){
                    let resumeId= rd[i].value;
                    let rid=$("#findrid").val();
                    console.log(resumeId);
                    console.log(rid);
                    count++;
                    // 提交的代码
                    layer.close(send);
                    $("#update-layer").css("display", "none");
                    $.post('/hire/job/send',{resumeId:resumeId,recruitmentId:rid},function (res) {
                        if(res.code=="200"){
                            layer.msg("投递成功");
                            // 投递成功后需要修改样式
                            $("#application").html("已申请");
                            $("#application").attr("disabled",true);
                        }else if(res.code=="502"){
                            layer.msg("抱歉,你已被拉黑")
                        }else if(res.code=="501"){
                            layer.msg(res.msg)
                        }else{
                            layer.msg("很抱歉,请稍后重试");
                        }
                    });

                }
            }

            if(count==0){
                layer.msg("请至少选择一份简历");
            }
            return false;
        });
    });
}

function add_collection(recruitmentId) {
    $.post('/hire/job/add', {recruitmentId: recruitmentId}, function (res) {
        if (res.code == "200") {
            let id = $("#findrid").val();
            layer.msg("收藏成功");
            $("#dem3").load('/hire/job/recruitment/recruitmentbutton', {id: id})
        }
    })
    // alert(recruitmentId)
}

function detel_blacklist(recruitmentId) {
    // alert(companyId)
    $.post("/hire/job/detel", {recruitmentId: recruitmentId}, function (res) {
        if (res.code == "200") {
            layer.msg("屏蔽成功");
            let id = $("#findrid").val();
            $("#dem3").load("/hire/job/recruitment/recruitmentbutton", {id: id})
        }
    })
}
function view_resume(resumeId) {
    window.open("/hire/resume/resume_preview?resumeId=" + resumeId);
}
function edit_resume(resumeId) {
    window.open("/hire/resume/resume_make?resumeId=" + resumeId);
}

// function searchresume(resumeId) {
//     // alert(resumeId)
//     window.location = "/hire/resume/resume_preview?id=" + resumeId;
//
// }

function find_cid(obj) {
    let id = obj.children[0].value;
    window.location = "/hire/job/company/companyinfo?id=" + id;
}

function find2_cid(obj) {
    let id = obj.children[0].value;
    window.location = "/hire/job/company/companyinfo?id=" + id;
}

$(function () {
    let id = $("#findrid").val();
    // console.log(id)
    $("#dem3").load("/hire/job/recruitment/recruitmentbutton", {id: id})
});

$(function () {
    let addressCity=document.getElementById("addr").value;
    // console.log(addressCity)
    var map = new BMapGL.Map('addresscity');
    map.centerAndZoom(new BMapGL.Point(116.331398,39.897445), 18);
    map.enableScrollWheelZoom(true);
    //创建地址解析器实例
    var myGeo = new BMapGL.Geocoder();
    // 将地址解析结果显示在地图上，并调整地图视野
    // console.log(addressCity)
    myGeo.getPoint(addressCity, function(point){
        if(point){
            map.centerAndZoom(point, 18);
            map.addOverlay(new BMapGL.Marker(point, {title: addressCity}))
        }else{
            alert('您选择的地址没有解析到结果！');
        }
    }, '苏州市')
})


